import request from '@/utils/request';

export async function getStandFileInfoByPage(params: any) {
  return request('/api/design/getStandFileInfoByPage', {
    method: 'POST',
    data: params,
  });
}

export async function addStandFileInfo(params: any) {
  return request('/api/design/addStandFileInfo', {
    method: 'POST',
    data: params,
  });
}

export async function updateStandFileInfo2(params: any) {
  return request('/api/design/updateStandFileInfo2', {
    method: 'POST',
    data: params,
  });
}

// 图纸上传
export async function uploadStandFileInfoDrawing(para: any) {
  return request('/api/design/uploadStandFileInfoDrawing', {
    method: 'POST',
    requestType: 'form',
    headers: {
      'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundaryX72QZDdfwlF5U73J',
    },
    data: para.file,

    params: {
      standTypeCode: para.standTypeCode,
      standTypeDesc: para.standTypeDesc,
      category: para.category,
      memo: para.memo,
      standTypeId: para.standTypeId,
      standTypeName: para.standTypeName,
    },
  });
}

// BOM上传
export async function uploadStandFileInfoBom(para: any) {
  return request('/api/design/uploadStandFileInfoBom', {
    method: 'POST',
    requestType: 'form',
    headers: {
      'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundaryX72QZDdfwlF5U73J',
    },
    data: para.file,
    params: {
      standTypeCode: para.standTypeCode,
      standTypeDesc: para.standTypeDesc,
      category: para.category,
      memo: para.memo,
      standTypeId: para.standTypeId,
      standTypeName: para.standTypeName,
    },
  });
}

// 获取附件分页信息
export async function getStandFileInfoByStandTypeIdAndCategoryPage(params: any) {
  return request('/api/design/getStandFileInfoByStandTypeIdAndCategoryPage', {
    method: 'POST',
    data: params,
  });
}

export async function delStandFileInfo(params: any) {
  return request('/api/design/delStandFileInfo', {
    method: 'POST',
    data: params,
  });
}

export async function exportStandFileInfo(params: any) {
  return request('/api/design/exportStandFileInfo', {
    method: 'POST',
    data: params,
    responseType: 'blob',
  });
}

export async function getStandFileType(params: any) {
  return request('/api/design/getStandFileType', {
    method: 'POST',
  });
}

export async function getProductTypeList(params: any) {
  return request('/api/design/getProductTypeList', {
    method: 'POST',
  });
}

export async function downloadFile(para: any) {
  return request('/api/design/downloadFile', {
    method: 'GET',
    responseType: 'blob',
    params: {
      standFileId: para.standFileId,
    },
  });
}

// 获取图纸类型
export async function getDrawingTypeList(params: any) {
  return request('/api/design/getDrawingTypeList', {
    method: 'POST',
  });
}

// 切换图纸/BOM启用状态
export async function switchStandFileInfo(para: any) {
  return request('/api/design/switchStandFileInfo', {
    method: 'POST',
    requestType: 'form',
    params: {
      category: para.category,
      standFileInfoId: para.standFileInfoId,
      standTypeId: para.standTypeId,
      status: para.status,
    },
  });
}

// 获取url
export async function getPreviewUrl(params: any) {
  return request('/api/design/getPreviewUrl', {
    method: 'POST',
    data: params,
  });
}

export default {
  getStandFileInfoByPage,
  addStandFileInfo,
  updateStandFileInfo2,
  delStandFileInfo,
  exportStandFileInfo,
};
